package a05_Interface.interfaceTest;

import a05_Interface.interfaceTest.*;

/**
 * @Author quan
 * @Description 知识点：关于接口的实现案例
 * @Date 2023/3/1 14:42
 */
public class TestDemo {
    public static void main(String[] args) {
        Dog dog = new Dog("元宝",3);
        Cat cat = new Cat("来福",2);
        Duck duck = new Duck("招财",5);
        //调用方法
        funRun(dog);
        funRun(cat);
        funRun(duck);

        funSwim(dog);
        funSwim(duck);

        funFly(duck);
    }
    //知识点：注意写法，这里传入的参数是IRun接口类型的对象：就是实现了该接口的对象
    public static void funRun(IRun obj1){
        obj1.run();
    }

    public static void funSwim(ISwim obj2){
        obj2.swim();
    }

    public static void funFly(IFly obj3){
        obj3.fly();
    }
}
